package setting

import (
	"github.com/gin-gonic/gin"
	"gopkg.in/ini.v1"
)

var ServerAddress string
var ServerName string
var EmailCaptchaMaxAge int
var CookieMaxAge int
var ImgCaptchaMaxAge int
var ServerMode string

func initServer(config *ini.File) error {
	section := config.Section("server")
	ServerAddress = section.Key("addr").MustString(":8080")
	ServerName = section.Key("server_name").MustString("Chicken Portal Service")
	EmailCaptchaMaxAge = section.Key("email_captcha_max_age").MustInt(10) * 60
	CookieMaxAge = section.Key("cookie_max_age").MustInt(30) * 24 * 60 * 60
	ImgCaptchaMaxAge = section.Key("img_captcha_max_age").MustInt(10) * 60
	ServerMode = section.Key("mode").MustString(gin.ReleaseMode)
	return nil
}
